import {reqGetFloorListDate,reqGetBannerListDate, reqGetCategoryListDate} from '../../api'

const state = {
    categoryList:[],
    bannerList: [],
    floorList:[],
}

const actions = {
    async  getCategoryListData(context) {
        const result = await reqGetCategoryListDate()
        if(result.code === 200) {
            context.commit('GET_CATEGORY_LIST_DATA', result.data)
        }else{
            console.log(result.message);
        }

    },
    async getBannerListDate({commit}) {
        const result = await reqGetBannerListDate()
        
        if(result.code === 200) {
            commit('SAVE_BANNER_LIST_DATA', result.data)
        }
    },
    async geFloorListDate({commit}) {
        const result = await reqGetFloorListDate()
        if(result.code === 200) {
            commit('SAVE_FLOOR_LIST_DATA', result.data)
        }
    },

}

const mutations = {
    GET_CATEGORY_LIST_DATA(state, list) {
        state.categoryList = list
    },
    SAVE_BANNER_LIST_DATA(state, list) {
        state.bannerList = list
    },
    SAVE_FLOOR_LIST_DATA(state, list) {
        state.floorList = list
    },
}

const getters = {}

export default {
    namespaced:true,
    state,
    actions,
    mutations,
    getters,
}